import { createRouter, createWebHashHistory } from 'vue-router';  
import Home from '../components/Home.vue';  
import Profile from '../components/Profile.vue';  
import TodoList from '../components/TodoList.vue';  
import OddSumCalculator from '../components/OddSumCalculator.vue';  
import Gitee from '../components/Gitee.vue';  
import { useAuthStore } from '@/stores/auth';  
import Login from '../components/Login.vue'; 
import Codelover from '../components/Codelover.vue';
import Score from '../components/Score.vue'
const routes = [  
  {  
    path: '/',  
    name: 'Home',  
    component: Home,  
  },  
  {  
    path: '/profile',  
    name: 'Profile',  
    component: Profile,  
  },  
  {  
    path: '/todo',  
    name: 'TodoList',  
    component: TodoList,  
  },  
  {  
    path: '/odd-sum',  
    name: 'OddSumCalculator',  
    component: OddSumCalculator,  
  },  
  {  
    path: '/gitee',  
    name: 'Gitee',  
    component: Gitee,  
  },  
  {
    path: '/login',
    name: 'Login',
    component: Login,
  },
  {
    path: '/codelover',
    name: 'Codelover',
    component: Codelover,
  },
  {  
    path: '/score',  
    name: 'Score',  
    component: Score,  
  },  
];  
  
const router = createRouter({  
  history: createWebHashHistory(), 
  routes, 
});  
router.beforeEach((to, from, next) => {  
  const authStore = useAuthStore();  
  if (to.path !== '/login' && !authStore.isLoggedIn) {  
    next('/login');  
  } else {  
    next();   
  }  
});   
export default router;